﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HalfpipeDemo.Data.Service;
using HalfpipeDemo.Web.Models;

namespace HalfpipeDemo.Web.Controllers
{
    public class EmployeeController : Controller
    {
        private readonly INorthwindUnitOfWork _unitOfWork;

        public ActionResult Index()
        {
            return View();
        }

        public EmployeeController(INorthwindUnitOfWork unitOfWork)
        {
            this._unitOfWork = unitOfWork;
        }

        public ActionResult Supervisors()
        {
            var model = from e in _unitOfWork.Employees.SelectAllSupervisors()
                        select new SupervisorListRow
                        {
                            Name = e.FirstName + " " + e.LastName,
                            SupervisedCount = e.Supervised.Count()
                        };
            return View(model);
        }
    }
}
